<template>
  <div class='addclient-container'>
    <el-dialog :title="judge==1?'添加客户端':'编辑客户端名称'"
               :visible.sync="dialogVisible"
               width="30%"
               :before-close="handleClose">
      <el-form :model="form"
               :inline="true"
               label-width="100px">
        <el-col :span="24"
                class="content-style">
          <el-form-item prop="username"
                        id="headInput">
            <el-input v-model="form.addClient"
                      style="width:100%!important;"></el-input>
          </el-form-item>
        </el-col>

      </el-form>
      <span id="headSubmit">

        <el-button type="primary"
                   @click="onSubmit">提 交</el-button>
      </span>
    </el-dialog>
    <el-col :span="24"
            class="col-24">
      <el-col :span="4">
        <el-button type="primary"
                   @click="onAdd">
          添加客户端
        </el-button>
      </el-col>
      <el-col :span="20">
        &nbsp;
      </el-col>
    </el-col>
    <el-table :data='tableData'
              height="310"
              :header-cell-style="{background:'#f5f5f5'}"
              border
              id="midTableSpace">

      <el-table-column label='序号'
                       align='center'
                       type="index"
                       width="60px"
                       show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop='clientname'
                       label='客户端名称'
                       align='center'
                       show-overflow-tooltip>
      </el-table-column>
      <el-table-column label="操作"
                       width="185px"
                       align="center"
                       show-overflow-tooltip>
        <template slot-scope="scope">
          <el-button size="mini"
                     type="text"
                     @click="onEdit">编辑
          </el-button>
          <el-button size="mini"
                     type="text"
                     @click="onDelete(scope.row.admin_id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination @current-change='handlePageChange'
                   :current-page='requestParam.page'
                   :page-sizes="[10]"
                   background
                   layout='total,sizes,prev, pager, next, jumper'
                   :total='total_count'
                   align='center'>
    </el-pagination>

  </div>
</template>
<script>
import { versionManagementApi } from "@/services/SystemSetting";
export default {
  data () {
    return {
      judge: '',//判断是新增还是修改弹框
      dialogVisible: false,
      requestParam: {
        page: 1,
        page_size: 10
      },
      tableData: [
        {
          id: '1',
          clientname: '建筑APP',
        },
        {
          id: '2',
          clientname: 'pad领导版',
        }
      ],
      form: {
        addClient: '',
      },
      total_page: 0,
      total_count: 0,

    }
  },
  methods: {
    //新增
    onAdd () {
      this.judge = 1;
      this.dialogVisible = true;
    },
    handlePageChange (page) {

    },
    //点击弹框右上角的关闭事件
    handleClose (done) {
      this.dialogVisible = false;
    },
    //编辑事件
    onEdit () {
      this.judge = 2;
      this.dialogVisible = true;
    },
    //删除事件
    onDelete (id) {
      this.$confirm('此操作将永久删除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {





      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除!'
        });
      });
    },
    //提交事件
    onSubmit () {
      //judge==1新增否则执行修改
      if (this.judge == 1) {
        this.dialogVisible = false;

      } else {
        this.dialogVisible = false
      }

    }
  },
  created () {

  },
  mounted () {

  }
}
</script>
<style scoped lang='scss'>
#midTableSpace {
  margin-bottom: 20px;
}
#headSubmit {
  text-align: center;
  display: block;
  margin-top: 20px;
}
#headInput {
  width: 100% !important;
}
.addclient-container {
  padding: 20px;
  .col-24 {
    margin-bottom: 20px !important;
  }
  .content-style {
    /deep/ .el-form-item__content {
      line-height: 40px;
      position: relative;
      font-size: 14px;
      width: 100% !important;
    }
  }
}
</style>
